import math
import numpy as np
import pandas as pd


# x:列向量,dim:将列向量从1列映射到dim列,sigma自己设定的
def rbfmap(x, dim, sigma):
    X = np.zeros((x.shape[0], dim))
    for i in range(dim):
        s = 1
        for j in range(i):
            if j == 0:
                j = 1
            s = s * j
        t = sigma ** (2*i)

        for n in range(len(x)):
           xx1 = x[n] * x[n]
           e = math.exp(- xx1 / (2 * (sigma ** 2)))
           xx2 = x[n] ** i
           s = math.sqrt(1 / (s * t)) * e * xx2
           X[n, i] = s
    return X


if __name__ == '__main__':
    df = pd.read_excel("data1.xlsx", header=0)
    x = df.iloc[:, 13]
    x = np.array(x)
    print(x)
    # rbfmap只能将一个向量映射到高维
    X = rbfmap(x, 3, 200000)
    np.save('13', X)
    np.file = np.load('13.npy')
    np_to_csv = pd.DataFrame(data=np.file)
    np_to_csv.to_csv('13.csv')
    print(X)



